$(function() {

	initIconSelect();

	$("input[class=hasParentLevel]").on("click", function() {
		if ($(this).val() == 0) {

			getMenuList(1, 0, "LevelOne");

			$(".selectMenu").show();
		} else {
			$(".selectMenu").hide();
			$(".LevelTwo").hide();
			$("input[name=level]").val(1);
			$("input[name=pid]").val(0);
		}
	})

	$("#LevelOne").on("change", function() {
		var thisMenuId = $(this).find("option:selected").attr("menuId");
		$("input[name=pid]").val(thisMenuId);
		getMenuList(2, thisMenuId, "LevelTwo");
		$("input[name=level]").val(2);
		$(".LevelTwo").show();
	});

	$("#LevelTwo").on("change", function() {
		var thisMenuId = $(this).find("option:selected").attr("menuId");
		$("input[name=pid]").val(thisMenuId);
		$("input[name=level]").val(3);
	});

	$("input[class=hasLink]").on(
			"click",
			function() {
				if ($(this).val() == 2) {
					$(".modelSelect").show();
					$("input[name=isLink]").val(2);

					$
							.post(getUrlBySuffix("/menuAdmin/getAllModule"),
									{}, function(data) {
										var list = eval(data);
										var _html = "";
										var thishtml = $("#modelSelect")
												.children().first().prop(
														"outerHTML");
										for (var i = 0; i < list.length; i++) {

											var _tempHtml = "<option id='"
													+ list[i].id + "' value='"
													+ list[i].id
													+ "' data-tokens='"
													+ list[i].name + "'>"
													+ list[i].name
													+ "</option>";
											_html += _tempHtml;
										}
										$("#modelSelect").html("");
										$("#modelSelect")
												.html(thishtml + _html);
										$("#modelSelect").attr(
												"data-live-search", "true");
										$("#modelSelect").selectpicker(
												'refresh');
									});
					$(".menuSelectUrl").show();
					$(".modelSelect").show();
				} else {
					$("input[name=isLink]").val(0);
					$(".menu-function").hide();
					$("input[name=menuUrl]").val("");
				}
			})

	$("#modelSelect").on(
			"change",
			function() {
				var thisModuleId = $(this).find("option:selected").attr("id");
				$.post(getUrlBySuffix("/menuAdmin/getFunctionByModuleId"), {
					moduleId : thisModuleId
				}, function(data) {
					var list = eval(data);
					var _html = "";
					var thishtml = $("#functionSelect").children().first()
							.prop("outerHTML");
					for (var i = 0; i < list.length; i++) {
						if (list[i].methodType == 0) {
							var _tempHtml = "<option id='" + list[i].id
									+ "' value='" + list[i].id
									+ "' data-tokens='" + list[i].name
									+ "' functionUrl='" + list[i].url + "'>"
									+ list[i].name + "</option>";
							_html += _tempHtml;
						}

					}
					$("#functionSelect").html("");
					$("#functionSelect").html(thishtml + _html);
					$("#functionSelect").attr("data-live-search", "true");
					$("#functionSelect").selectpicker('refresh');
				});
				$(".functionSelect").show();

			})

	$("#functionSelect")
			.on(
					"change",
					function() {
						var thisFunctionId = $(this).find("option:selected")
								.attr("id");
						var thisFunctionUrl = $(this).find("option:selected")
								.attr("functionUrl");
						$("input[name=menuUrl]").val(thisFunctionUrl);
						$("input[name=relationFunction]").val(thisFunctionId);
						$("input[name=menuUrlShow]").val(thisFunctionUrl);
					})

	$("#iconSelect").on("change", function() {
		var thisIconValue = $(this).find("option:selected").val();
		$(".icon-postion").html("<i class='fa " + thisIconValue + "'></i>");
		$("input[name=iconId]").val(thisIconValue);
	})

	$("#commitBtn").on("click", function() {

		if ($("input[class=hasParentLevel]:checked").val() == "0") {
			if ($("input[name=pid]").val() == "") {
				swal("提示", "请选择一个父级菜单");
				return;
			}
		}
		if ($("input[name=isLink]:checked").val() == "2") {
			if ($("input[name=menuUrl]").val() == "") {
				swal("提示", "请选择一个功能");
				return;
			}
		}
		if ($("input[name=menuName]").val() == "") {
			swal("提示", "菜单名称不能为空");
			return;
		}

		var params = {
			pid : Number($("input[name=pid]").val()),
			menuUrl : $("input[name=menuUrl]").val(),
			isLink : Number($("input[name=hasLink]:checked").val()),
			menuName : $("input[name=menuName]").val(),
			menuLevel : $("input[name=level]").val(),
			relationFunction : Number($("input[name=relationFunction]").val()),
			iconId : $("input[name=iconId]").val(),
			sort : Number($("input[name=menuSort]").val())
		}
		sendParams(params);
	})
	editbuttonFunction();
	insertNewRoot();
	deleteButtonEvent();
})

function sendParams(params) {
	$.post(getUrlBySuffix("/menuAdmin/insertMenuInfo"), params, function(json) {
		// console.log(JSON.stringify(json));
		if (json == 1) {
			swal({
				title : "恭喜",
				text : "菜单添加成功",
				type : "success",
				confirmButtonText : "确定"
			}, function() {
				location.reload();
			});
		} else if (json == 2) {
			swal({
				title : "提示",
				text : "该菜单名称已经存在",
				type : "error"
			});
		} else {
			swal({
				title : "提示",
				text : "菜单添加失败",
				type : "error"
			});
		}
	});
}

function getMenuList(level, pid, elementId) {
	var params = {
		level : level,
		pid : pid
	}
	$.post(getUrlBySuffix("/menuAdmin/getMenuInfo"), params,
			function(data) {
				var list = eval(data);
				var _html = "";
				var thishtml = $("#" + elementId + "").children().first().prop(
						"outerHTML");
				for (var i = 0; i < list.length; i++) {

					var _tempHtml = "<option menuId='" + list[i].id
							+ "' menuLevel='" + list[i].menuLevel + "'>"
							+ list[i].menuName + "</option>";
					_html += _tempHtml;
				}
				$("#" + elementId).html("");
				$("#" + elementId).html(thishtml + _html);
				$("#" + elementId).selectpicker('refresh');
			});

}

function initIconSelect() {
	var _options = "";
	for ( var key in iconList) {
		var _tempOption = "<option value='" + iconList[key] + "'>" + key
				+ "</option>";
		_options += _tempOption;
	}
	$("#iconSelect").append(_options);
	$("#iconSelect").selectpicker('refresh');

}

var getMenuTreeData = function(data) {
	var nodeData = new Array();
	for (var i = 0; i < data.length; i++) {
		var _nodeMessage = {
			text : data[i].menuName,
			id : data[i].id,
			nodes : (data[i].menuRoleVOs == null ? null
					: getMenuTreeData(data[i].menuRoleVOs)),
			tags : data[i].MenuLevel

		}
		nodeData.push(_nodeMessage);
	}
	return nodeData;
}

function editbuttonFunction() {
	$(".edit_button")
			.on(
					"click",
					function() {
						var flagIsLink = false;
						var menuSourceId = $(this).siblings(".clickTree").find(
								"input[name=menuIdEdit]").val();

						$
								.ajax({
									url : getUrlBySuffix("/menuAdmin/getMenuSourceById"),
									async : false,
									type : 'POST',
									data : {
										menuSourceId : menuSourceId
									},
									success : function(json) {
										var menuSource = json.list[0];
										console.log(menuSource);
										$("input[name=editId]").val(
												menuSource["id"]);
										$("input[name=editMenuName]").val(
												menuSource["menuName"]);
										$("input[name=editMenuUrl]").val(
												menuSource["menuUrl"]);
										$("input[name=menuSortEdit]").val(
												menuSource["sort"]);
										$("input[name=relationFunctionEdit]")
												.val(
														menuSource["relationFunction"]);
										$("input[name=hasLinkEditValue]").val(
												menuSource["isLink"]);
										$("input[name=iconEditId]").val(menuSource["iconId"]);
										$(".icon-edit-postion").html("<i class='fa " + menuSource["iconId"] + "'></i>");
										if (menuSource["isLink"] == 2) {
											flagIsLink = true;
											$("input[name=hasLinkEdit]:eq(0)")
													.attr("checked", 'checked');
										} else {
											$("input[name=hasLinkEdit]:eq(1)")
													.attr("checked", 'checked');
										}
									},
									error : function(jqXHR, textStatus,
											errorThrown) {
										console.log(errorThrown);
									}
								})
						if (flagIsLink) {

							$
									.ajax({
										url : getUrlBySuffix("/function/findByUrl"),
										data : {
											url : $("input[name=editMenuUrl]")
													.val()
										},
										async : false,
										type : 'POST',
										success : function(data) {
											var list = eval(data.list);
											for (var i = 0; i < list.length; i++) {
												if (list[i].methodType == 0) {
													$(
															"input[name=moduleIdEdit]")
															.val(
																	list[i]["module"]);
												}
											}
										},
										error : function(jqXHR, textStatus,
												errorThrown) {
											console.log(errorThrown);
										}
									})

							$
									.post(
											getUrlBySuffix("/menuAdmin/getAllModule"),
											{},
											function(data) {
												var list = eval(data);
												var _html = "";
												var thishtml = $(
														"#modelSelectEdit")
														.children().first()
														.prop("outerHTML");
												for (var i = 0; i < list.length; i++) {
													if (list[i].id == $(
															"input[name=moduleIdEdit]")
															.val()) {
														var _tempHtml = "<option id='"
																+ list[i].id
																+ "' value='"
																+ list[i].id
																+ "' data-tokens='"
																+ list[i].name
																+ "'  selected='selected'>"
																+ list[i].name
																+ "</option>";
													} else {
														var _tempHtml = "<option id='"
																+ list[i].id
																+ "' value='"
																+ list[i].id
																+ "' data-tokens='"
																+ list[i].name
																+ "'>"
																+ list[i].name
																+ "</option>";
													}
													_html += _tempHtml;
												}
												$("#modelSelectEdit").html("");
												$("#modelSelectEdit").html(
														thishtml + _html);
												$("#modelSelectEdit").attr(
														"data-live-search",
														"true");
												$("#modelSelectEdit")
														.selectpicker('refresh');
											});

							$
									.post(
											getUrlBySuffix("/menuAdmin/getFunctionByModuleId"),
											{
												moduleId : $(
														"input[name=moduleIdEdit]")
														.val()
											},
											function(data) {
												var list = eval(data);
												var _html = "";
												var thishtml = $(
														"#functionSelectEdit")
														.children().first()
														.prop("outerHTML");
												for (var i = 0; i < list.length; i++) {
													if (list[i].methodType == 0) {
														if (Number($(
																"input[name=relationFunctionEdit]")
																.val()) == list[i].id) {
															var _tempHtml = "<option id='"
																	+ list[i].id
																	+ "' value='"
																	+ list[i].id
																	+ "' data-tokens='"
																	+ list[i].name
																	+ "' functionUrl='"
																	+ list[i].url
																	+ "' selected='selected'>"
																	+ list[i].name
																	+ "</option>";
														} else {
															var _tempHtml = "<option id='"
																	+ list[i].id
																	+ "' value='"
																	+ list[i].id
																	+ "' data-tokens='"
																	+ list[i].name
																	+ "' functionUrl='"
																	+ list[i].url
																	+ "'>"
																	+ list[i].name
																	+ "</option>";
														}

														_html += _tempHtml;
													}

												}
												$("#functionSelectEdit").html(
														"");
												$("#functionSelectEdit").html(
														thishtml + _html);
												$("#functionSelectEdit").attr(
														"data-live-search",
														"true");
												$("#functionSelectEdit")
														.selectpicker('refresh');
											});

							$(".functionSelectEdit").show();
							$(".menuSelectUrledit").show();
							$(".modelSelectEdit").show();
							$("#menu-edit-modal").modal("show");
						} else {
							$("#menu-edit-modal").modal("show");
						}

					})
	editSelectEventhasData();
	editHasLink();
	updataMenuSourceInfo();
	editIconButtonEvent();
}
//修改展示图标
function editIconButtonEvent(){
	var _options = "";
	for ( var key in iconList) {
		var _tempOption = "<option value='" + iconList[key] + "'>" + key
				+ "</option>";
		_options += _tempOption;
	}
	$("#iconEditSelect").append(_options);
	$("#iconEditSelect").selectpicker('refresh');
	$("#iconEditSelect").on(
			"change",
			function() {
				var thisIconValue = $(this).find("option:selected").val();
				$(".icon-edit-postion").html(
						"<i class='fa " + thisIconValue + "'></i>");
				$("input[name=iconEditId]").val(thisIconValue);
			})
}
function editHasLink() {
	$("input[name=hasLinkEdit]").on(
			"click",
			function() {
				if ($(this).val() == 2) {
					$("input[name=hasLinkEditValue]").val(2);

					$
							.post(getUrlBySuffix("/menuAdmin/getAllModule"),
									{}, function(data) {
										var list = eval(data);
										var _html = "";
										var thishtml = $("#modelSelectEdit")
												.children().first().prop(
														"outerHTML");
										for (var i = 0; i < list.length; i++) {

											var _tempHtml = "<option id='"
													+ list[i].id + "' value='"
													+ list[i].id
													+ "' data-tokens='"
													+ list[i].name + "'>"
													+ list[i].name
													+ "</option>";
											_html += _tempHtml;
										}
										$("#modelSelectEdit").html("");
										$("#modelSelectEdit").html(
												thishtml + _html);
										$("#modelSelectEdit").attr(
												"data-live-search", "true");
										$("#modelSelectEdit").selectpicker(
												'refresh');
									});
					$(".menuSelectUrledit").show();
					$(".modelSelectEdit").show();
				} else {
					$("input[name=hasLinkEditValue]").val(0);

					$(".functionSelectEdit").hide();
					$(".menuSelectUrledit").hide();
					$(".modelSelectEdit").hide();
					$("input[name=editMenuUrl]").val("");
					$("input[name=relationFunctionEdit]").val("");
				}
			})
}
function editSelectEventhasData() {
	$("#modelSelectEdit").on(
			"change",
			function() {
				var thisModuleId = $(this).find("option:selected").attr("id");
				$.post(getUrlBySuffix("/menuAdmin/getFunctionByModuleId"), {
					moduleId : thisModuleId
				}, function(data) {
					var list = eval(data);
					var _html = "";
					var thishtml = $("#functionSelectEdit").children().first()
							.prop("outerHTML");
					for (var i = 0; i < list.length; i++) {
						if (list[i].methodType == 0) {
							var _tempHtml = "<option id='" + list[i].id
									+ "' value='" + list[i].id
									+ "' data-tokens='" + list[i].name
									+ "' functionUrl='" + list[i].url + "'>"
									+ list[i].name + "</option>";
							_html += _tempHtml;
						}

					}
					$("#functionSelectEdit").html("");
					$("#functionSelectEdit").html(thishtml + _html);
					$("#functionSelectEdit").attr("data-live-search", "true");
					$("#functionSelectEdit").selectpicker('refresh');
				});
				$(".functionSelectEdit").show();

			})

	$("#functionSelectEdit")
			.on(
					"change",
					function() {
						var thisFunctionId = $(this).find("option:selected")
								.attr("id");
						var thisFunctionUrl = $(this).find("option:selected")
								.attr("functionUrl");
						$("input[name=editMenuUrl]").val(thisFunctionUrl);
						$("input[name=relationFunctionEdit]").val(
								thisFunctionId);
					})
}

function updataMenuSourceInfo() {
	$("#edit-btn").on(
			"click",
			function() {
				var params = {
					id : Number($("input[name=editId]").val()),
					menuName : $("input[name=editMenuName]").val(),
					relationFunction : Number($(
							"input[name=relationFunctionEdit]").val()),
					menuUrl : $("input[name=editMenuUrl]").val()==""?"null":$("input[name=editMenuUrl]").val(),
					isLink : Number($("input[name=hasLinkEditValue]").val()),
					sort : Number($("input[name=menuSortEdit]").val()),
					iconId:$("input[name=iconEditId]").val()
				}
				var url = getRoot() + "/menuAdmin/update";
				$.postHttp(params, url, function(json) {
					if (json == 1) {
						swal({
							title : "提示",
							text : "菜单修改成功",
							type : "success",
							confirmButtonText : "确定"
						}, function() {
							location.reload();
						});
						$("#menu-edit-modal").modal("hide");

						$("#searchBtn").trigger("click");
					} else {
						swal("失败", "未能从服务器获取正确信息", 'error');
					}
				});
			})
}
// 新建子节点系列
function insertNewRoot() {
	$(".add_button")
			.on(
					"click",
					function() {
						var pid = $(this).parent("span").siblings(".clickTree")
								.find("input[name=menuIdEdit]").val();
						var level = $(this).parent("span").siblings(
								".clickTree").find("input[name=menuLevel]")
								.val();
						$("#insertRootForm").find("input[name=insertRootPid]")
								.val(pid);
						$("#insertRootForm")
								.find("input[name=insertRootLevel]").val(
										(level * 1) + 1);
						$("#menu-insert-root-modal").modal("show");
					})
	insertRootHasLink();
	insertRootSelectEventhasData();
	initInsertRootIconSelect();
	insertRootBtn();
	upAndDownButtonEvent();
}

function insertRootHasLink() {
	$("input[name=insertHasLink]").on(
			"click",
			function() {
				if ($(this).val() == 2) {
					$("input[name=insertRootIsLink]").val(2);

					$
							.post(getUrlBySuffix("/menuAdmin/getAllModule"),
									{}, function(data) {
										var list = eval(data);
										var _html = "";
										var thishtml = $("#modelSelectInsert")
												.children().first().prop(
														"outerHTML");
										for (var i = 0; i < list.length; i++) {

											var _tempHtml = "<option id='"
													+ list[i].id + "' value='"
													+ list[i].id
													+ "' data-tokens='"
													+ list[i].name + "'>"
													+ list[i].name
													+ "</option>";
											_html += _tempHtml;
										}
										$("#modelSelectInsert").html("");
										$("#modelSelectInsert").html(
												thishtml + _html);
										$("#modelSelectInsert").attr(
												"data-live-search", "true");
										$("#modelSelectInsert").selectpicker(
												'refresh');
									});
					$(".menuSelectUrlInsert").show();
					$(".modelSelectInsert").show();
				} else {
					$("input[name=insertRootIsLink]").val(0);

					$(".functionSelectInsert").hide();
					$(".menuSelectUrlInsert").hide();
					$(".modelSelectInsert").hide();
					$("input[name=insertMenuUrl]").val("");
				}
			})
}
function insertRootSelectEventhasData() {
	$("#modelSelectInsert")
			.on(
					"change",
					function() {
						var thisModuleId = $(this).find("option:selected")
								.attr("id");
						$
								.post(
										getUrlBySuffix("/menuAdmin/getFunctionByModuleId"),
										{
											moduleId : thisModuleId
										},
										function(data) {
											var list = eval(data);
											var _html = "";
											var thishtml = $(
													"#functionSelectInsert")
													.children().first().prop(
															"outerHTML");
											for (var i = 0; i < list.length; i++) {
												if (list[i].methodType == 0) {
													var _tempHtml = "<option id='"
															+ list[i].id
															+ "' value='"
															+ list[i].id
															+ "' data-tokens='"
															+ list[i].name
															+ "' functionUrl='"
															+ list[i].url
															+ "'>"
															+ list[i].name
															+ "</option>";
													_html += _tempHtml;
												}

											}
											$("#functionSelectInsert").html("");
											$("#functionSelectInsert").html(
													thishtml + _html);
											$("#functionSelectInsert").attr(
													"data-live-search", "true");
											$("#functionSelectInsert")
													.selectpicker('refresh');
										});
						$(".functionSelectInsert").show();

					})

	$("#functionSelectInsert")
			.on(
					"change",
					function() {
						var thisFunctionId = $(this).find("option:selected")
								.attr("id");
						var thisFunctionUrl = $(this).find("option:selected")
								.attr("functionUrl");
						$("input[name=insertMenuUrl]").val(thisFunctionUrl);
						$("input[name=insertRootRelationFunction]").val(
								thisFunctionId);
					})
}
function initInsertRootIconSelect() {
	var _options = "";
	for ( var key in iconList) {
		var _tempOption = "<option value='" + iconList[key] + "'>" + key
				+ "</option>";
		_options += _tempOption;
	}
	$("#iconInsertSelect").append(_options);
	$("#iconInsertSelect").selectpicker('refresh');
	$("#iconInsertSelect").on(
			"change",
			function() {
				var thisIconValue = $(this).find("option:selected").val();
				$(".icon-insert-postion").html(
						"<i class='fa " + thisIconValue + "'></i>");
				$("input[name=iconInsertId]").val(thisIconValue);
			})

}

function insertRootBtn() {
	$("#insert-btn").on(
			"click",
			function() {
				if ($("input[name=insertRootIsLink]:checked").val() == "2") {
					if ($("input[name=insertMenuUrl]").val() == "") {
						swal("提示", "请选择一个功能");
						return;
					}
				}
				if ($("input[name=insertMenuName]").val() == "") {
					swal("提示", "菜单名称不能为空");
					return;
				}

				var params = {
					pid : Number($("input[name=insertRootPid]").val()),
					menuUrl : $("input[name=insertMenuUrl]").val(),
					isLink : Number($("input[name=insertHasLink]:checked")
							.val()),
					menuName : $("input[name=insertMenuName]").val(),
					menuLevel : $("input[name=insertRootLevel]").val(),
					relationFunction : Number($(
							"input[name=insertRootRelationFunction]").val()),
					iconId : $("input[name=iconInsertId]").val(),
					sort : Number($("input[name=menuSortInsert]").val())
				}
				console.log(params);
				sendParams(params);
			})
}

// 删除节点系列
function deleteButtonEvent() {
	$(".delete_button").on(
			"click",
			function() {
				// 检查是否有子菜单，有的话则不删除
				var childrenMenu = $(this).parent("span").siblings("ul").find(
						"li");
				if (childrenMenu.length > 0) {
					swal("提示", "该菜单下有子菜单，请先删除子菜单");
					return false;
				} else {
					var url = getUrlBySuffix("/menuAdmin/removeMenu");
					var params = {
						menuSourceId : $(this).parent("span").siblings(
								".clickTree").find("input[name=menuIdEdit]")
								.val()
					}

					swal({
						title : "确定删除?",
						text : "你将删除该菜单!",
						type : "warning",
						showCancelButton : true,
						confirmButtonColor : "#DD6B55",
						confirmButtonText : "是, 删除!",
						cancelButtonText : "不删除!",
						closeOnConfirm : false,
						closeOnCancel : false
					}, function(isConfirm) {
						if (isConfirm) {
							$.post(url, params, function(json) {
								if (json && json.success) {
									swal("提示", "成功删除", "success");
									location.reload();
								} else {
									swal("提示", "删除失败，请联系管理员", "error");
								}
							})
						} else {
							swal("取消删除", "该菜单未删除 :)", "error");
						}
					});

				}
			})
}
// 上下移动部分
function upAndDownButtonEvent() {
	$(".up_button")
			.on(
					"click",
					function() {
						var prevEle = $(this).parent("span").parent("li")
								.prev();
						var thisEleSort = $(this).parent("span").siblings(
								".clickTree").find("input[name=menuSort]")
								.val();
						var thisEleMenuId = $(this).parent("span").siblings(
								".clickTree").find("input[name=menuIdEdit]")
								.val();
						console.log(prevEle);
						if (prevEle.length == 0) {
							swal("提示", "在顶部不可上移");
							return false;
						}
						var prevEleSort = $(prevEle).find(
								"input[name=menuSort]").val();
						var prevEleMenuId = $(prevEle).find(
								"input[name=menuIdEdit]").val();
						var paramsValue = "[{'id':'" + thisEleMenuId
								+ "','sort':'" + prevEleSort + "'},{'id':'"
								+ prevEleMenuId + "','sort':'" + thisEleSort
								+ "'}]";
						var params = {
							menuSources : paramsValue
						}
						var url = getUrlBySuffix("/menuAdmin/batchUpdataMenuSource");
						$.post(url, params, function(json) {
							if (json && json.success) {
								swal("提示", "上移成功");
								location.reload();
							} else {
								swal("提示", "上移失败，请联系管理员");
							}
						})
					})

	$(".down_button").on(
			"click",
			function() {
				var nextEle = $(this).parent("span").parent("li").next();
				if (nextEle.length == 0) {
					swal("提示", "在底部不可下移");
					return false;
				}
				var thisEleSort = $(this).parent("span").siblings(".clickTree")
						.find("input[name=menuSort]").val();
				var thisEleMenuId = $(this).parent("span").siblings(
						".clickTree").find("input[name=menuIdEdit]").val();
				var nextEleSort = $(nextEle).children(".clickTree").find(
						"input[name=menuSort]").val();
				var nextEleMenuId = $(nextEle).children(".clickTree").find(
						"input[name=menuIdEdit]").val();
				var paramsValue = "[{'id':'" + thisEleMenuId + "','sort':'"
						+ nextEleSort + "'},{'id':'" + nextEleMenuId
						+ "','sort':'" + thisEleSort + "'}]";
				var params = {
					menuSources : paramsValue
				}
				var url = getUrlBySuffix("/menuAdmin/batchUpdataMenuSource");
				$.post(url, params, function(json) {
					if (json && json.success) {
						location.reload();
						swal("提示", "下移成功");
					} else {
						swal("提示", "下移失败，请联系管理员");
					}
				})

			})
}